package jvm.jtacck.db.records;

/**
 * 
 * @author Chris Gamble
 * 
 *         Represents a Status a Specimen can have. A Status consists of a
 *         unique id, a name, and a description of the status.
 *         
 *         There are currently 3 valid statuses.
 *         Status(1, 'Waiting', 'The shipment is waiting to be picked up.'),
 *         Status(2, 'In Transit', 'The shipment has been picked up and is on its way to the LAB.'),
           Status(3, 'Arrived', 'The shipment has arrived at is final destination.');
 */
public class Status extends Record {

    private static final long serialVersionUID = -4260083509589747379L;
    public final int status_id;
    public final String name;
    public final String description;

    /**
     * Constructs a Status
     * 
     * @param id
     *            the unique id of the status.
     *            NON-NULLABLE
     * @param name
     *            the name of the status.
     * @param description
     *            an english description of the status.
     */
    public Status(int id, String name, String description) {
        this.status_id = id;
        this.name = name;
        this.description = description;
    }
    
    @Override
    public boolean equals(Object o){
        if (o instanceof Status) {
            Status other = (Status) o;
            return (status_id == other.status_id) &&
                    checkString(name, other.name) &&
                    checkString(description, other.description);
        }
        return false;
    }
    
    public boolean checkString(String s1, String s2) {
        if (s1 == null) {
            return s2 == null;
        }else {
            return s1.equals(s2);
        }
    }
    
    @Override
    public int hashCode() {
        return status_id + name.hashCode() + 
        description.hashCode();
    }
    
    public String toString() {
        return status_id + ": " + name + ", " + description + ".";
    }
}
